<template>


<table class="table table-bordered">

    <thead>
        <tr>
            <th> 房型id </th>
            <th> 房型名称 </th>
            <th> 房号 </th>
            <th> 房型居住人数 </th>
            <th> 状态 </th>
            <th> 操作 </th>
        </tr>

    </thead>

    <tbody v-for="item in show1 ">
        

        <tr>
            <th> {{ item.fid }} </th>
            <th>  {{ item. fname}} </th>
            <th>  {{ item. hid}} </th>
            <th>  {{ item.num }} </th>
            <th>  {{ item.isTou }} </th>
            <th> <button @click="IsDel(item.fid)">删除</button> </th>
        </tr>

    </tbody>
            <button @click="Fenye1('S')">首页</button>
            <button @click="Fenye1('L')">上一页</button>
            <button @click="Fenye1('N')">下一页</button>
            <button @click="Fenye1('M')">尾页</button>




</table>




</template>


<script  setup lang="ts">

const IsDel=(id:number)=>{

    if(!confirm('确定删除吗'))
{
    return ;
}
    axios.delete('https://localhost:7099/api/FangXing/IsDel',{params:{
            id:id,


    }}).then(res=>{
        if(res.data>0)
            {
            alert('删除成功')
            show();
            }
            else
            {
                alert('删除失败')
            }

    })


}


const Fenye1=(chool:string )=>{


            switch(chool){

                    case'S':
                            Fenye.value.s=1
                    break;

                    case'M':
                            Fenye.value.s=Fenye.value.Zy
                    break;

                    case'L':
                                if(Fenye.value.s<=1)
                                {
                                    alert('页码不能小于1')
                                    return ;
                                }
                                Fenye.value.s-=1;

                          
                    break;

                    case'N':
                    if(Fenye.value.s>= Fenye.value.Zy)
                                {
                                    alert('页码不能大于总页')
                                    return ;
                                }
                                Fenye.value.s+=1;
                    break;

            }

            show();


}




import axios from 'axios';
import {onMounted, ref} from'vue'
import { compileStyle } from 'vue/compiler-sfc';

const show1=ref([{
    "fid": 1,
      "fname": "string",
      "hid": "string",
      "num": 0,
      "isTou": true,
      "isDel": true
}])

onMounted(()=>{

    show();
})

const Fenye=ref({


    s:1,
    m:3,
    count:0,
    Zy:0,
})


const show=()=>{


    axios.get('https://localhost:7099/api/FangXing/ShowFangXing',{params:{

        s:Fenye.value.s,
        m:Fenye.value.m,

    }}).then(res=>{

        show1.value=res.data.data
        Fenye.value.Zy=res.data.zy
        Fenye.value.count=res.data.count


    })

}



</script>